@echo off
cls
echo =====================================================================
echo                    营养系统菜品信息自动处理系统
echo =====================================================================
echo.
echo 执行时间: %date% %time%
echo.

echo [系统状态检查]
echo --------------
echo 1. 检查任务是否存在...
schtasks /query /tn "营养系统菜品信息自动处理" >nul 2>&1
if %errorlevel% equ 0 (
    echo    ✓ 定时任务已配置
) else (
    echo    ✗ 定时任务未配置
)

echo.
echo 2. 检查相关文件...
if exist "D:\wwwroot\yingyang\runtime\auto_process_dish_info.php" (
    echo    ✓ PHP处理脚本存在
) else (
    echo    ✗ PHP处理脚本缺失
)

if exist "D:\wwwroot\yingyang\runtime\run_dish_processing_with_log.bat" (
    echo    ✓ 批处理执行脚本存在
) else (
    echo    ✗ 批处理执行脚本缺失
)

echo.
echo [数据库处理结果]
echo ----------------
echo 未处理菜品数量:
mysql -u root -proot yingyang -e "SELECT COUNT(*) as unprocessed_count FROM fa_food_dish WHERE ai_called = 0;" -N

echo.
echo 已处理菜品数量:
mysql -u root -proot yingyang -e "SELECT COUNT(*) as processed_count FROM fa_food_dish WHERE ai_called = 1;" -N

echo.
echo 最近处理的5个菜品:
mysql -u root -proot yingyang -e "SELECT id, name, cook_time, LEFT(steps, 50) as steps_preview FROM fa_food_dish WHERE ai_called = 1 ORDER BY updatetime DESC LIMIT 5;" 

echo.
echo [日志文件检查]
echo --------------
cd /d D:\wwwroot\yingyang\runtime
if exist dish_processing_*.log (
    echo 最新的日志文件:
    for /f "delims=" %%i in ('dir dish_processing_*.log /b /o:-d') do (
        echo    %%i
        goto :log_check_done
    )
    :log_check_done
) else (
    echo    未找到日志文件
)

echo.
echo =====================================================================
echo                    检查完成
echo =====================================================================
echo.
echo 管理命令:
echo schtasks /query /tn "营养系统菜品信息自动处理"     - 查看任务状态
echo schtasks /run /tn "营养系统菜品信息自动处理"       - 立即运行任务
echo schtasks /delete /tn "营养系统菜品信息自动处理"    - 删除任务
echo.
pause